#include <jni.h>
#include <string.h>
#include <math.h>




	//List<Float> listdata = new ArrayList<Float>();

	 float old_x_acc;
	 float old_y_acc;
	 float old_z_acc;

	 long FirstTime = 0;
	 long mDeltime = 0;

 float Toggle = 1.5f;  //触发值

 JNIEXPORT jboolean JNICALL Java_use_1ndk_JNI_isShake(JNIEnv * pEnv, jclass thiz, jfloatArray list)
//	jboolean Java_use_ndk_JNI_isShake(JNIEnv* pEnv, jobject thiz , jfloatArray list)
	{


		int size = pEnv->GetArrayLength(list);
	//	if(length <= 3)
	//		return;

		jfloat* listdata = pEnv->GetFloatArrayElements(list, NULL);


		float sum_delta = 0;
		for (int i = 0; i < size; i++) {
			float t = listdata[i];
			sum_delta += fabs(t);

		}


		float result = sum_delta / size; // 取平均值
		if (result > Toggle) { // delta值能够触发

			return true;

		}


		return false;


	}


